Note that the alternative implementations will not produce bit-for-bit
identical results, and in the case of random number distributions will
produce an entirely different stream of random variates.
File: gsl-ref.info, Node: Support for different numeric types, Next: Compatibility with C++, Prev: Alternative optimized functions, Up: Using the library
Support for different numeric types
===================================
Many functions in the library are defined for different numeric
types. This feature is implemented by varying the name of the function
with a type-related modifier -- a primitive form of C++ templates. The
modifier is inserted into the function name after the initial module
prefix. The following table shows the function names defined for all
the numeric types of an imaginary module `gsl_foo' with function `fn',
gsl_foo_fn double
gsl_foo_long_double_fn long double
gsl_foo_float_fn float
gsl_foo_long_fn long
gsl_foo_ulong_fn unsigned long
gsl_foo_int_fn int
gsl_foo_uint_fn unsigned int
gsl_foo_short_fn short
gsl_foo_ushort_fn unsigned short
gsl_foo_char_fn char
gsl_foo_uchar_fn unsigned char
The normal numeric precision `double' is considered the default and
does not require a suffix. For example, the function `gsl_stats_mean'
computes the mean of double precision numbers, while the function
`gsl_stats_int_mean' computes the mean of integers.
A corresponding scheme is used for library defined types, such as
`gsl_vector' and `gsl_matrix'. In this case the modifier is appended
to the type name. For example, if a module defines a new
type-dependent struct or typedef `gsl_foo' it is modified for other
types in the following way,
gsl_foo double
gsl_foo_long_double long double
gsl_foo_float float
gsl_foo_long long
gsl_foo_ulong unsigned long
gsl_foo_int int
gsl_foo_uint unsigned int
gsl_foo_short short
gsl_foo_ushort unsigned short
gsl_foo_char char
gsl_foo_uchar unsigned char
When a module contains type-dependent definitions the library provides
individual header files for each type. The filenames are modified as
shown in the below. For convenience the default header includes the
definitions for all the types. To include only the double precision
header, or any other specific type, file use its individual filename.
#include <gsl/gsl_foo.h> All types listed below
#include <gsl/gsl_foo_double.h> double
#include <gsl/gsl_foo_long_double.h> long double
#include <gsl/gsl_foo_float.h> float
#include <gsl/gsl_foo_long.h> long
#include <gsl/gsl_foo_ulong.h> unsigned long
#include <gsl/gsl_foo_int.h> int
#include <gsl/gsl_foo_uint.h> unsigned int
#include <gsl/gsl_foo_short.h> short
#include <gsl/gsl_foo_ushort.h> unsigned short
#include <gsl/gsl_foo_char.h> char
#include <gsl/gsl_foo_uchar.h> unsigned char
File: gsl-ref.info, Node: Compatibility with C++, Next: Aliasing of arrays, Prev: Support for different numeric types, Up: Using the library
Compatibility with C++
======================
The library header files automatically define functions to have
`extern "C"' linkage when included in C++ programs.
File: gsl-ref.info, Node: Aliasing of arrays, Prev: Compatibility with C++, Up: Using the library
Aliasing of arrays
==================
The library assumes that arrays, vectors and matrices passed as
arguments are not aliased and do not overlap. This allows the library to
use additional optimizations, and removes the need to handle overlapping
memory regions as a special case. If overlapping arguments are used
then the results of such functions will be undefined.
File: gsl-ref.info, Node: Error handling in GSL, Next: Mathematical Functions, Prev: Using the library, Up: Top
Error handling in GSL
*********************
This chapter describes the way that GSL functions report and handle
errors. By examining the status information returned by every GSL
function you can determine whether it succeeded or failed, and if it
failed you can find out what the precise cause of failure was. You can
also define your own error handling functions to modify the default
behavior of the library.
* Menu:
* Error reporting::
* Error handlers::
* Using GSL error reporting in your own functions::
This function computes the value of \sqrt{x^2 + y^2} in a way that
avoid overflow. It provides an alternative to the system function
`hypot(x,y)'.
File: gsl-ref.info, Node: Testing the Sign of Numbers, Next: Testing for Odd and Even Numbers, Prev: Elementary Functions, Up: Mathematical Functions
Testing the Sign of Numbers
===========================
- Macro: GSL_SIGN (x)
This macro returns the sign of X. It is defined as `((x) >= 0 ? 1
: -1)'. Note that with this definition the sign of zero is positive
(regardless of its IEEE sign bit).
File: gsl-ref.info, Node: Testing for Odd and Even Numbers, Next: Maximum and Minimum functions, Prev: Testing the Sign of Numbers, Up: Mathematical Functions
Testing for Odd and Even Numbers
================================
- Macro: GSL_IS_ODD (n)
This macro evaluates to 1 if N is odd and 0 if N is even. The
argument N must be of integer type.
- Macro: GSL_IS_EVEN (n)
This macro is the opposite of `GSL_IS_ODD(n)'. It evaluates to 1 if
N is even and 0 if N is odd. The argument N must be of integer
type.
File: gsl-ref.info, Node: Maximum and Minimum functions, Prev: Testing for Odd and Even Numbers, Up: Mathematical Functions
Maximum and Minimum functions
=============================
- Macro: GSL_MAX (a, b)
This macro returns the maximum of A and B. It is defined as `((a)
> (b) ? (a):(b))'.
- Macro: GSL_MIN (a, b)
This macro returns the minimum of A and B. It is defined as `((a)
< (b) ? (a):(b))'.
- Function: extern inline double GSL_MAX_DBL (double A, double B)
This function returns the maximum of the double precision numbers
A and B using an inline function. The use of a function allows for
type checking of the arguments as an extra safety feature. On
platforms where inline functions are not available the macro
`GSL_MAX' will be automatically substituted.
- Function: extern inline double GSL_MIN_DBL (double A, double B)
This function returns the minimum of the double precision numbers
A and B using an inline function. The use of a function allows for
type checking of the arguments as an extra safety feature. On
platforms where inline functions are not available the macro
`GSL_MIN' will be automatically substituted.
- Function: extern inline int GSL_MAX_INT (int A, int B)
- Function: extern inline int GSL_MIN_INT (int A, int B)
These functions return the maximum or minimum of the integers A
and B using an inline function. On platforms where inline
functions are not available the macros `GSL_MAX' or `GSL_MIN' will
be automatically substituted.
- Function: extern inline long double GSL_MAX_LDBL (long double A,
long double B)
- Function: extern inline long double GSL_MIN_LDBL (long double A,
long double B)
These functions return the maximum or minimum of the long doubles A
and B using an inline function. On platforms where inline
functions are not available the macros `GSL_MAX' or `GSL_MIN' will
be automatically substituted.
File: gsl-ref.info, Node: Complex Numbers, Next: Vectors and Matrices, Prev: Mathematical Functions, Up: Top
Complex Numbers
***************
The functions described in this chapter provide support for complex
numbers. The algorithms take care to avoid unnecessary intermediate
underflows and overflows, allowing the functions to evaluated over the
as much of the complex plane as possible. (FIXME: this still needs to be
done for the csc,sec,cot,csch,sech,coth functions).
For multiple-valued functions the branch cuts have been chosen to
follow the conventions of Abramowitz and Stegun in the `Handbook of
Mathematical Functions'. The functions return principal values which are
the same as those is GNU Calc, which in turn are the same as those in
`Common Lisp, The Language (Second Edition)' (1) and the HP-28/48
series of calculators.
* Menu:
* Complex numbers::
* Properties of complex numbers::
* Complex arithmetic operators::
* Elementary Complex Functions::
* Complex Trigonometric Functions::
* Inverse Complex Trigonometric Functions::
* Complex Hyperbolic Functions::
* Inverse Complex Hyperbolic Functions::
* Complex Number References and Further Reading::
---------- Footnotes ----------
(1) The first edition of `Common Lisp, The Language' used different